eliminate unnecessary string conversions.
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 13 Feb 2022 20:05:56 +0000 (13:05 -0700)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 13 Feb 2022 20:05:56 +0000 (13:05 -0700)
toString().to* is suspicious, QStringRef and QStringView probably
can be converted directly to *.

geo.cc
ik3d.cc
mapfactor.cc
osm.cc
tef_xml.cc
xol.cc

diff --git a/geo.cc b/geo.cc
index bd84344e2598db27036172439dd70d5edbe3ebbe..cb4b64067fe6774834c685fe91497610529beefa 100644 (file)
--- a/geo.cc
+++ b/geo.cc
@@ -64,8 +64,8 @@ static void GeoReadLoc()
         wpt->description = reader.readElementText();
       } else if (current_tag == u"/loc/waypoint/coord") {
         QXmlStreamAttributes a = reader.attributes();
-        wpt->latitude = a.value("lat").toString().toDouble();
-        wpt->longitude = a.value("lon").toString().toDouble();
+        wpt->latitude = a.value("lat").toDouble();
+        wpt->longitude = a.value("lon").toDouble();
       } else if (current_tag == u"/loc/waypoint/type") {
         wpt->icon_descr = reader.readElementText();
       } else if (current_tag == u"/loc/waypoint/link") {
diff --git a/ik3d.cc b/ik3d.cc
index ea2991947553d354fe8a2e28acbad56e05040ed5..12192f4e79429a015221f932445ddcca266b3fd1 100644 (file)
--- a/ik3d.cc
+++ b/ik3d.cc
@@ -74,10 +74,10 @@ static void
 iktobj_waypt(xg_string, const QXmlStreamAttributes* attrv)
 {
   if (attrv->hasAttribute("X")) {
-    waypt->longitude = attrv->value("X").toString().toDouble();
+    waypt->longitude = attrv->value("X").toDouble();
   }
   if (attrv->hasAttribute("Y")) {
-    waypt->latitude = attrv->value("Y").toString().toDouble();
+    waypt->latitude = attrv->value("Y").toDouble();
   }
 }
 
index 28710d0c2bbf331a34fe3ad96e05a0cbdf75cced..83b6d612f8b2582bd4820eb4233145629649cbd2 100644 (file)
@@ -45,8 +45,8 @@ void MapfactorFormat::MapfactorRead()
 
         QXmlStreamAttributes a = reader.attributes();
         wpt->shortname = a.value("name").toString();
-        wpt->latitude = a.value("lat").toString().toDouble() / milliarcseconds;
-        wpt->longitude = a.value("lon").toString().toDouble() / milliarcseconds;
+        wpt->latitude = a.value("lat").toDouble() / milliarcseconds;
+        wpt->longitude = a.value("lon").toDouble() / milliarcseconds;
       }
     }
 
diff --git a/osm.cc b/osm.cc
index a34c5b9b28be250c96aea2750e7c3c4557a387cb..8929aa6c91a67add2d71441a9040a3aad39ffa1a 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -454,10 +454,10 @@ OsmFormat::osm_node(xg_string /*unused*/, const QXmlStreamAttributes* attrv)
   // if (attrv->hasAttribute("user")) ; // ignored
 
   if (attrv->hasAttribute("lat")) {
-    wpt->latitude = attrv->value("lat").toString().toDouble();
+    wpt->latitude = attrv->value("lat").toDouble();
   }
   if (attrv->hasAttribute("lon")) {
-    wpt->longitude = attrv->value("lon").toString().toDouble();
+    wpt->longitude = attrv->value("lon").toDouble();
   }
 
   if (attrv->hasAttribute("timestamp")) {
@@ -589,10 +589,10 @@ OsmFormat::osm_way_center(xg_string /*unused*/, const QXmlStreamAttributes* attr
   wpt->wpt_flags.fmt_use = 1;
 
   if (attrv->hasAttribute("lat")) {
-    wpt->latitude = attrv->value("lat").toString().toDouble();
+    wpt->latitude = attrv->value("lat").toDouble();
   }
   if (attrv->hasAttribute("lon")) {
-    wpt->longitude = attrv->value("lon").toString().toDouble();
+    wpt->longitude = attrv->value("lon").toDouble();
   }
 }
 
index 77004f075ae4b9d09151cb6ec22d65c713686ec3..475969750934f0c235070cf18b1517678c167ea9 100644 (file)
@@ -54,7 +54,7 @@ TefXMLFormat::tef_start(xg_string /*unused*/, const QXmlStreamAttributes* attrv)
         valid = true;
       }
     } else if (attr.name().compare(QLatin1String("Version"), Qt::CaseInsensitive) == 0) {
-      version = attr.value().toString().toDouble();
+      version = attr.value().toDouble();
     }
   }
 
@@ -85,7 +85,7 @@ void
 TefXMLFormat::tef_list_start(xg_string /*unused*/, const QXmlStreamAttributes* attrv)
 {
   if (attrv->hasAttribute("ItemCount")) {
-    item_count = attrv->value("ItemCount").toString().toUInt();
+    item_count = attrv->value("ItemCount").toUInt();
   }
 }
 
diff --git a/xol.cc b/xol.cc
index b5cd7ea4076a5feda138db9b34e81e21596b0e2f..05aafa7e7d7a223c63daefaefdb3aaf67ae5cceb 100644 (file)
--- a/xol.cc
+++ b/xol.cc
@@ -87,12 +87,12 @@ static void xol_shape(xg_string, const QXmlStreamAttributes* attrv) {
     }
 
     if (attrv->hasAttribute("alt")) {
-      wpt_->altitude = attrv->value("alt").toString().toDouble();
+      wpt_->altitude = attrv->value("alt").toDouble();
     }
 
     if (attrv->hasAttribute("timestamp")) {
       wpt_->creation_time = xml_parse_time(
-          attrv->value("timestamp").toString().toUtf8().constData());
+          attrv->value("timestamp").toString());
     }
 
     if (attrv->hasAttribute("icon")) {
@@ -121,11 +121,11 @@ static void xol_waypt(xg_string, const QXmlStreamAttributes* attrv) {
   int x = 0, y = 0;
 
   if (attrv->hasAttribute("y")) {
-    y = attrv->value("y").toString().toInt();
+    y = attrv->value("y").toInt();
   }
 
   if (attrv->hasAttribute("x")) {
-    x = attrv->value("x").toString().toInt();
+    x = attrv->value("x").toInt();
   }
 
   GPS_Math_Swiss_EN_To_WGS84(x, y, &wpt_->latitude, &wpt_->longitude);